#!/usr/bin/env python

from sys import argv, exit

if len(argv) != 3:
    print("Usage: rsem-refseq-extract-primary-assembly input_top_level_assembly.fna output_primary_assembly.fna")
    exit(-1)

writeOut = True
with open(argv[1]) as fin:
    with open(argv[2], "w") as fout:
        for line in fin:
            line = line.strip()
            if line[0] == '>':
               writeOut = line.rfind("Primary Assembly") >= 0
            if writeOut:
                fout.write(line + "\n")
 
